'''
Case Type： security-policy
Case Name： 设置密码不可重用次数设置为-1
Owner    :  opentestcase003
Create at:  2020/11/10
Description:  1.设置参数：gs_guc reload -N all -I all -c "password_reuse_max = -1";
Expect:  1.报错，参数不支持负数
History:
    created:  2020/11/10   createby:  opentestcase003
'''
import unittest
from yat.test import Node
from yat.test import macro

from testcase.utils.CommonSH import *
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger

class Privategrant(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        self.logger.info('------------Opengauss_Function_Security_Policy_Case0068 start--------------')
        self.userNode = Node('PrimaryDbUser')
        self.DB_ENV_PATH = macro.DB_ENV_PATH
        self.sh_primy = CommonSH('PrimaryDbUser')
        self.Constant = Constant()
    def test_schema(self):
        excute_cmd1 = f'''
                    source {self.DB_ENV_PATH};
                    gs_guc set -N all -I all -c "password_reuse_max=-1";
                    '''
        self.logger.info(excute_cmd1)
        msg1 = self.userNode.sh(excute_cmd1).result()
        self.logger.info(msg1)
        self.assertTrue(msg1.find("The value -1 is outside the valid range for parameter") > -1)

    def tearDown(self):
        self.logger.info('--------------Opengauss_Function_Security_Policy_Case0068 end---------------')
